package com.t235.gc.device.service;

import com.t235.gc.dao.DeviceCabinetDao;
import com.t235.gc.entity.DeviceCabinet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备商品柜表(DeviceCabinet)表服务接口
 *
 * @author makejava
 * @since 2021-03-24 08:45:22
 */
@Service
public class DeviceCabinetService {
    @Autowired
    private DeviceCabinetDao deviceCabinetDao;

    public List<DeviceCabinet> getGoodsByDeviceId(Long deviceId) {
        return deviceCabinetDao.getGoodsByDeviceId(deviceId);
    }

    public DeviceCabinet getDeviceCabinetByName(String goodsName,Long deviceId) {
        return deviceCabinetDao.getDeviceCabinetByName(goodsName,deviceId);
    }


    public int addDeviceCabinetByCabinetId(Long cabinetid, Long goodsid) {
        return deviceCabinetDao.addDeviceCabinetByCabinetId(cabinetid,goodsid);
    }

    public List<DeviceCabinet> getStockByIsStock(Long deviceId) {
        int num=200;//假设货道库存上限20
        List<DeviceCabinet> list=deviceCabinetDao.getStockByIsStock(deviceId);
        for (DeviceCabinet dc:list){
            dc.setStockNum(num-dc.getStockqty());
        }
        return list;
    }


    public void stockAdd(Long cabinetid, int num) {
        deviceCabinetDao.stockAdd(cabinetid,num);
    }

    public DeviceCabinet getGoodsByCabinetId(Long cabinetId) {
        int num=200;//假设货道库存上限20
        DeviceCabinet dc=deviceCabinetDao.getGoodsByCabinetId(cabinetId);
        dc.setStockNum(num-dc.getStockqty());
        return dc;
    }
}
